package com.yanqu.road.server.pb;

import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.entity.tradewar.UserTradeWarBattle;
import com.yanqu.road.pb.tradewar.TradeWarProto;
import com.yanqu.road.server.manger.player.UserMgr;

public class TradeWarBattlePb {
    public static TradeWarProto.TradeWarBattleTempMsg.Builder parseTradeWarBattleTempMsg(UserTradeWarBattle userTradeWarBattle, long score) {
        if(null == userTradeWarBattle){
            return null;
        }
        TradeWarProto.TradeWarBattleTempMsg.Builder msg = TradeWarProto.TradeWarBattleTempMsg.newBuilder();
        msg.addAllMyPatronsIdList(userTradeWarBattle.getPatronsList());
        msg.setBuyBuffTimes(userTradeWarBattle.getBuyBuffTimes());
        msg.setMyScore(score);
        msg.setEnemyUserId(userTradeWarBattle.getEnemyUserId());
        msg.setEnemyNickName(userTradeWarBattle.getEnemyNickName());
        msg.setEnemyTitleId(userTradeWarBattle.getEnemyTitleId());
        msg.setEnemyDecoration(userTradeWarBattle.getEnemyDecoration());
        msg.setEnemyVipExp(userTradeWarBattle.getEnemyVipExp());
        msg.setEnemyPatronsCount(userTradeWarBattle.getEnemyPatronsCount());
        msg.setEnemyScore(userTradeWarBattle.getEnemyScore());
        msg.setEnemyCity(userTradeWarBattle.getEnemyCity());
        msg.setWarTimes(userTradeWarBattle.getWarTimes());
        UserInfo userInfo = UserMgr.getUserInfo(userTradeWarBattle.getEnemyUserId());
        if (userTradeWarBattle.getEnemyUserId() > 0 && userInfo != null) {
            msg.setHideVipAndAddress(userInfo.getHideVipAndAddress());
        } else {
            msg.setHideVipAndAddress(0);
        }

        return msg;
    }
}
